package cn.itcast.nems.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;

/**
 * <p>
 * 优惠类型：金额|CASH、折扣|DISCOUNT。注：来自于优惠规则的类型
 * </p>
 *
 * @author zhouwei
 * @since 2023/9/11 10:39 PM
 **/
@Getter
@AllArgsConstructor
public enum DiscountTypeEnum {
    CASH("金额"), DISCOUNT("折扣") ;
    
    private final String name;
    
    public static DiscountTypeEnum getByValue(@NonNull Integer value) {
        switch (value) {
            case 0 -> {
                return DiscountTypeEnum.CASH;
            }
            case 1 -> {
                return DiscountTypeEnum.DISCOUNT;
            }
            default -> throw new IllegalArgumentException("未知的优惠类型值: " + value);
        }
    }
}
